package com.study.io.bio.demo.input;

import java.io.ByteArrayInputStream;
import java.io.IOException;

/**
 * 字节数组缓存输入流
 *
 * @author wuxj
 */
public class ByteArrayInputStreamDemo {

    public static void main(String[] args) throws IOException {
        ByteArrayInputStream bais = new ByteArrayInputStream("123".getBytes());
        byte[] by1 = new byte[1024];
        bais.read(by1);
        System.out.println(new String((by1)));

        //reset 之后再次读取
        bais.reset();
        byte[] by2 = new byte[1024];
        bais.read(by2);
        System.out.println(new String((by2)));
    }
}
